import java.util.Date;

public class Master extends Student implements Manageable {
    private double aver;
    private char thesisLevel;

    public Master() {
    }

    public Master(String name, char gender, Date birthDay, String school, String stuId, String category, double[] score, boolean status) {
        super(name, gender, birthDay, school, stuId, category, score, status);
    }

    public char getThesisLevel() {
        return thesisLevel;
    }

    public void setThesisLevel(char thesisLevel) {
        this.thesisLevel = thesisLevel;
    }

    @Override
    public double computeAverage() throws Exception {
        double product = 1;
        for (double score : score) {
            if (score < 0 || score > 100) {
                throw new MasterException("成绩不在0-100范围内: " + score);
            }
            product *= score;
        }
        aver = Math.pow(product, 1.0 / score.length);

        if (thesisLevel < 'A' || thesisLevel > 'E') {
            throw new MasterException("论文等级不在A-E范围内: " + thesisLevel);
        }

        return aver;
    }

    @Override
    public boolean getPass() {
        return aver >= 80 && thesisLevel >= 'C';
    }

    @Override
    public void printInfo() {
        System.out.println("姓名: " + name);
        System.out.println("性别: " + gender);
        System.out.println("出生日期: " + birthDay);
        System.out.println("学校: " + school);
        System.out.println("学号: " + stuId);
        System.out.println("类别: " + category);
        System.out.print("成绩: ");
        for (double s : score) {
            System.out.print(s + " ");
        }
        System.out.println("\n论文等级: " + thesisLevel);
        System.out.println("学位授予状态: " + (status ? "已授予硕士学位" : "未授予硕士学位"));
    }

    @Override
    public String getDegree() {
        return status ? "硕士学位" : "未满足学位授予条件";
    }
}
